<template>
  <div>
    <h1 v-if="visable">子组件</h1>
    <h2>父组件的值：{{childrenvalue}}</h2>
    <button @click="children">子组件按钮</button>
  </div>
</template>
<script>
export default {
  props:{
    childrenvalue:{
      type:String,
      required:true
    }
  },
  data() {
    return {
      visable: false,
      value:""
    };
  },
  methods: {
    init() {
      this.visable = true;
      this.value=this.childrenvalue;
      console.log(this.value);
      // 子组件显示
    },
    children(){
      console.log("子组件按钮触发");
      this.$emit("received","childrenvalue")

    }
  },
};
</script>
